<script setup lang="ts">
import { goto } from '@/utils/comm'
import { HeartSharp  } from '@vicons/ionicons5'

 
const props = defineProps({
  item: {} as any
});

const open_detail= (item:any)=> {
  item.path = "/home/detail"
  goto(item)
}

</script>

<template>
  <n-card class="card_new xiaoshou animated fadeIn card2"  :bordered="false"  content-style="padding:0"  @click="open_detail(props.item)" hoverable v-if="props.item.type==1">
    <template #cover style="width: 100%;height: 100%;">
      <n-image :src="props.item.cover" class="cover"  object-fit="cover" :style="props.item.type==1?'aspect-ratio: 1/1.3;':'aspect-ratio: 1/0.6;'" lazy  preview-disabled :intersection-observer-options="{ root: '#list'}">
        <template #placeholder  style="width: 100%;height: 100%;">
        <n-skeleton height="100%" width="100%" :sharp="false"  size="large"/> 
      </template>
      </n-image>
    </template>
    <div class="" style="display: flex;">
      <div style="flex: 1;display: flex;align-items: center;">
        <n-ellipsis :line-clamp="1" style="padding:0 3px;">
          {{props.item.name}}
        </n-ellipsis>
      </div>
    </div>
    
  </n-card>
  <n-card class="card_new xiaoshou animated fadeIn card2"  :bordered="false"  content-style="padding:0"  @click="open_detail(props.item)" hoverable v-else>
    <template #cover style="width: 100%;height: 100%;">
      <n-image :src="props.item.cover" class="cover"  object-fit="cover" :style="props.item.type==1?'aspect-ratio: 1/1.3;':'aspect-ratio: 1/0.6;'" lazy  preview-disabled :intersection-observer-options="{ root: '#list'}">
        <template #placeholder  style="width: 100%;height: 100%;">
        <n-skeleton height="100%" width="100%" :sharp="false"  size="large"/> 
      </template>
      </n-image>
    </template>
    <div class="longs" >
      {{props.item.longs}}
    </div>
    <div class="" style="display: flex;">
      <div style="flex: 1;display: flex;align-items: center;">
        <n-ellipsis :line-clamp="1" style="padding:0 3px;">
          {{props.item.name}}
        </n-ellipsis>
      </div>
      <div style="width: 70px;text-align: right;padding:0 3px;display: flex;justify-content: end;align-items: center;">
        <n-icon :component="HeartSharp"/>{{props.item.likes}}
      </div>
    </div>
    
  </n-card>
</template>

<style lang="scss" scoped> 
  .active{
    animation: flipInY;
    animation-duration: 1s;
  }
  .card2{
    padding:8px 8px;
    background-color: #4a4a4a7d;
    // &:hover{
    //   background-color: #4a4a4a7d;
    // }
  }
  .card_new{
    text-align: center;
    position: relative;
    width: 100%;
    height: 100%;
    .longs{
        position: absolute;
        top: 8px;
        right: 8px;
        padding: 2px 3px;
        text-align: center;
        overflow: hidden;
        border-radius: 2px;
        background: rgb(0, 0, 0,0.4);
      }
  }
  #image-scroll-container{
    animation: fadeIn 0.65s ease forwards;
  }
  .cover{
    width: 100%;
    height: 100%; 
    transform: translateZ(0);
    transition: transform 0.4s;
    border-radius: 5px;
    &:hover{
      transform: scale(1.1,1.1); 
    }
  }
  .card {
      width: 100%;
      aspect-ratio: 1/0.6;
      object-fit: cover;
      border-radius: 5px;
      background-size: 100% auto;
      overflow: hidden; 
      // backdrop-filter: blur(200px); //增加毛玻璃
    }
  .card_box{
      width: 100%;
      height: 100%;
      background: linear-gradient(to bottom,rgb(0, 0, 0,0.6), rgb(0, 0, 0,0.9));
      padding: 5px;
      display: flex;
      &:hover{
        .img{
          transform: scale(1.05,1.05); 
        }
      }
      .img{
        height: 100%;aspect-ratio: 0.75/1;border-radius: 5px;
        transition: transform 0.4s;
      }
      .name{
        color: #fff;width: auto;margin-left: 5px;font-size: 14px;display: flex;align-items: end;
      }
    }

.light-mode { 
  .card2{
    background-color: rgba(0,0,0,0.1);
    // &:hover{
    //   background-color: #4a4a4a7d;
    // }
  }
  .card_box{
    background: linear-gradient(to bottom,rgb(255, 255, 255,0.5), rgb(255, 255, 255,0.9));
    .name{
      color: #000;
    }
  }
  .longs{
        background: rgb(255,255,255,0.4);
  }
}
</style>